package com.yunxin.core.infra.persistence.mapper.order;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.yunxin.core.domain.model.order.OrderUserApply;
import com.yunxin.core.infra.persistence.entity.order.OrderUserApplyDO;
import com.yunxin.core.infra.persistence.entity.order.query.condition.OrderUserApplyPageCondition;
import com.yunxin.core.infra.persistence.entity.order.query.result.OrderUserApplyDetailResult;
import com.yunxin.core.infra.persistence.entity.order.query.result.OrderUserApplyInfoResult;
import com.yunxin.core.infra.persistence.entity.order.query.result.OrderUserApplyPageResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author zero°
 * @since 2023-06-02
 */
@DS("core")
@Mapper
public interface OrderUserApplyExtendMapper extends OrderUserApplyMapper {

    /**
     * 根据申请订单号查询用户申请订单详情
     * @param applyOrderNo applyOrderNo
     * @return OrderUserApplyDetailResult
     */
    OrderUserApplyDetailResult selectOrderUserApplyDetailByApplyOrderNo(@Param("applyOrderNo") String applyOrderNo);

    /**
     * 根据用户code查询用户最新的申请订单详情
     * @param userCode userCode
     * @return OrderUserApplyDetailResult
     */
    OrderUserApplyDetailResult selectLastOrderUserApplyDetailByUserCode(@Param("userCode") String userCode);

    /**
     * 根据用户code查询用户申请订单详情
     * @param userCode userCode
     * @return OrderUserApplyInfoResult
     */
    OrderUserApplyInfoResult selectOrderUserApplyDetailByUser(@Param("userCode") String userCode);

    /**
     * 根据申请订单号查询用户申请订单
     * @param applyOrderNo applyOrderNo
     * @return OrderUserApply
     */
    OrderUserApplyDO selectOrderUserApplyByApplyOrderNo(@Param("applyOrderNo") String applyOrderNo);

    /**
     * 分页查询用户申请订单列表总条数
     * @param condition condition
     * @return int
     */
    long countOrderUserApplyPageQuery(OrderUserApplyPageCondition condition);

    /**
     * 分页查询用户申请订单列表
     * @param condition condition
     * @return List<OrderUserApply>
     */
    List<OrderUserApplyPageResult> orderUserApplyPageQuery(OrderUserApplyPageCondition condition);

    /**
     * 根据手机号查询订单详情
     * @param phone
     * @return
     */
    OrderUserApply getIdByUserPhone(String phone);

    OrderUserApply selectOrderUserApplyAllocationByUserCode(@Param("userCode") String userCode,@Param("productId")Long productId);

    List<OrderUserApply>  selectOrderUserApplyAllocationByUserCode1(@Param("userCode")String userCode,@Param("productId") Long productId);
}
